﻿using System;
using System.Collections.Generic;
using System.Text;
using TarreOA.TarreOAModels;
using TarreOA.TarreOADAL;

namespace TarreOA.TarreOABLL
{
    public class UserCommunicationGroupLinkMantbService
    {
        /// <summary>
        /// 为指定通讯组添加联系人
        /// </summary>
        /// <param name="comGroupId"></param>
        /// <param name="groupLinkManName"></param>
        /// <param name="groupLinkManSec"></param>
        /// <param name="groupLinkManBirthday"></param>
        /// <param name="groupLinkManName2"></param>
        /// <param name="groupLinkManDurty"></param>
        /// <param name="groupLinkManUnitName"></param>
        /// <param name="groupLinkManUnitAddress"></param>
        /// <param name="groupLinkManUnitTelephone"></param>
        /// <param name="groupLinkManUnitFacsimile"></param>
        /// <param name="groupLinkManHomeAddress"></param>
        /// <param name="groupLinkManHomeTelephone"></param>
        /// <param name="groupLinkManHandset"></param>
        /// <param name="groupLinkManEmail"></param>
        /// <param name="groupLinkManOicq"></param>
        /// <param name="groupLinkManMsn"></param>
        /// <param name="groupLinkManRemark"></param>
        /// <param name="UserLoginName"></param>
        /// <returns></returns>
        public bool saveComGroupLinkManInfo(int comGroupId, string groupLinkManName, int groupLinkManSec, DateTime groupLinkManBirthday
            , string groupLinkManName2, string groupLinkManDurty, string groupLinkManUnitName, string groupLinkManUnitAddress
            , string groupLinkManUnitTelephone, string groupLinkManUnitFacsimile, string groupLinkManHomeAddress
            , string groupLinkManHomeTelephone, string groupLinkManHandset, string groupLinkManEmail, string groupLinkManOicq
            , string groupLinkManMsn, string groupLinkManRemark, string userLoginName)
        {
            bool state = false;
            UserCommunicationGroupLinkMantbDAO ucgLinkMantbDAO = new UserCommunicationGroupLinkMantbDAO();
            if (ucgLinkMantbDAO.saveComGroupLinkManInfo(comGroupId, groupLinkManName, groupLinkManSec, groupLinkManBirthday,                                groupLinkManName2, groupLinkManDurty, groupLinkManUnitName, groupLinkManUnitAddress, groupLinkManUnitTelephone,                               groupLinkManUnitFacsimile, groupLinkManHomeAddress, groupLinkManHomeTelephone, groupLinkManHandset, groupLinkManEmail,                 groupLinkManOicq, groupLinkManMsn, groupLinkManRemark, userLoginName) == 1)
            {
                state = true;
            }
            return state;
        }

        /// <summary>
        /// 根据通讯组编号查找该通讯组的联系人信息
        /// </summary>
        /// <param name="cgid"></param>
        /// <returns></returns>
        public List<UserCommunicationGroupLinkMantb> findByComGroupId(int cgid)
        {
            UserCommunicationGroupLinkMantbDAO ucgLinkManDAO = new UserCommunicationGroupLinkMantbDAO();
            return ucgLinkManDAO.findByComGroupId(cgid);
        }

        /// <summary>
        /// 根据通讯组联系人编号查找联系人信息
        /// </summary>
        /// <param name="cgLmid"></param>
        /// <returns></returns>
        public UserCommunicationGroupLinkMantb findByGroupLinkManId(int cgLmid)
        {
            UserCommunicationGroupLinkMantbDAO ucgLinkManDAO = new UserCommunicationGroupLinkMantbDAO();
            return ucgLinkManDAO.findByGroupLinkManId(cgLmid);
        }

        /// <summary>
        /// 根据通讯组联系人编号删除联系人信息
        /// </summary>
        /// <param name="cgLmid"></param>
        /// <returns></returns>
        public bool delComGroupLinkManByGroupLinkManId(int cgLmid)
        {
            bool state = false;
            UserCommunicationGroupLinkMantbDAO ucgLinkManDAO = new UserCommunicationGroupLinkMantbDAO();
            if (ucgLinkManDAO.delComGroupLinkManByGroupLinkManId(cgLmid) == 1)
            {
                state = true;
            }
            return state;
        }

         /// <summary>
        /// 根据通讯组联系人编号更改联系人信息
        /// </summary>
        /// <param name="cgLmid"></param>
        /// <param name="cgid"></param>
        /// <param name="cgLmName"></param>
        /// <param name="cgLmSec"></param>
        /// <param name="cgLmBirthday"></param>
        /// <param name="cgLmName2"></param>
        /// <param name="cgLmDuty"></param>
        /// <param name="cgLmUnitName"></param>
        /// <param name="cgLmUnitAddress"></param>
        /// <param name="cgLmUnitTelephone"></param>
        /// <param name="cgLmUnitFacsimile"></param>
        /// <param name="cgLmHomeAddress"></param>
        /// <param name="cgLmHomeTelephone"></param>
        /// <param name="cgLmHandset"></param>
        /// <param name="cgLmEmail"></param>
        /// <param name="cgLmOicq"></param>
        /// <param name="cgLmMsn"></param>
        /// <param name="cgLmRemark"></param>
        /// <returns></returns>
        public bool updateComGroupLinkManInfoByGroupLinkManId(int cgLmid, int cgid, string cgLmName, int cgLmSec, DateTime cgLmBirthday,
            string cgLmName2, string cgLmDuty, string cgLmUnitName, string cgLmUnitAddress, string cgLmUnitTelephone,
            string cgLmUnitFacsimile, string cgLmHomeAddress, string cgLmHomeTelephone, string cgLmHandset, string cgLmEmail,
            string cgLmOicq, string cgLmMsn, string cgLmRemark)
        {
            bool state = false;
            UserCommunicationGroupLinkMantbDAO ucgLinkManDAO = new UserCommunicationGroupLinkMantbDAO();
            if (ucgLinkManDAO.updateComGroupLinkManInfoByGroupLinkManId(cgLmid, cgid, cgLmName, cgLmSec, cgLmBirthday, cgLmName2,                   cgLmDuty, cgLmUnitName, cgLmUnitAddress, cgLmUnitTelephone, cgLmUnitFacsimile, cgLmHomeAddress, cgLmHomeTelephone,                 cgLmHandset, cgLmEmail, cgLmOicq, cgLmMsn, cgLmRemark) == 1)
            {
                state = true;
            }
            return state;
        }

        /// <summary>
        /// 根据联系人姓名查找当前用户的联系人信息
        /// </summary>
        /// <param name="lmName"></param>
        /// <param name="uln"></param>
        /// <returns></returns>
        public List<UserCommunicationGroupLinkMantb> findByLinkManNameAndUserLoginName(string lmName, string uln)
        {
            UserCommunicationGroupLinkMantbDAO ucgLinkManDAO = new UserCommunicationGroupLinkMantbDAO();
            return ucgLinkManDAO.findByLinkManNameAndUserLoginName(lmName, uln);
        }

        /// <summary>
        /// 根据联系人生日查找当前用户的联系人信息
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="uln"></param>
        /// <returns></returns>
        public List<UserCommunicationGroupLinkMantb> findByBirthdayAndUserLoginName(string startDate, string endDate, string uln)
        {
            UserCommunicationGroupLinkMantbDAO ucgLinkManDAO = new UserCommunicationGroupLinkMantbDAO();
            return ucgLinkManDAO.findByBirthdayAndUserLoginName(startDate, endDate, uln);
        }

        /// <summary>
        /// 根据用户的单位关键字查找用户联系人信息
        /// </summary>
        /// <param name="lmName"></param>
        /// <param name="uln"></param>
        /// <returns></returns>
        public List<UserCommunicationGroupLinkMantb> findByLinkManUnitNameAndUserLoginName(string lmUnitName, string uln)
        {
            UserCommunicationGroupLinkMantbDAO ucgLinkManDAO = new UserCommunicationGroupLinkMantbDAO();
            return ucgLinkManDAO.findByLinkManUnitNameAndUserLoginName(lmUnitName, uln);
        }
    }
}
